import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import AntDesign from 'react-native-vector-icons/AntDesign';
import { sizes, colors } from '../constants/theme';


export default function Status({ statusCode }) {
  let name;
  let iconName;
  let iconColor;
  switch (statusCode) {
    case 1:
      [name, iconName, iconColor] = ['执行结束', 'checkcircle', 'green'];
      break;
    case 0:
      [name, iconName, iconColor] = ['正在执行', 'play', colors.secondary];
      break;
    case 2:
      [name, iconName, iconColor] = ['执行异常', 'closecircle', 'red'];
      break;
    case 3:
      [name, iconName, iconColor] = ['等待执行', 'minuscircle', 'gray'];
      break;
    default: return null;
  }
  return (
    <View style={styles.status}>
      <Text style={{ fontSize: sizes.base, flex: 1 }}>
        状态：
        {name}
      </Text>
      <AntDesign name={iconName} size={sizes.base} style={{ color: iconColor, flex: 2 }} />
    </View>
  );
}

const styles = StyleSheet.create({
  status: {
    flexDirection: 'row',
    justifyContent: 'space-between',
    alignItems: 'center',
    marginBottom: sizes.sperate
  }
});
